﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;

namespace MyCore.Api
{
    public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {

                    //.UseKestrel().UseUrls("http://127.0.0.1:98")
                    //var config = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("hosting.json", optional: true).Build();
                    //var config = new ConfigurationBuilder().AddJsonFile("appsettings.json", optional: true).Build();
                    //var config = new ConfigurationBuilder().AddCommandLine(args).Build();
                    var config = new ConfigurationBuilder().SetBasePath(Environment.CurrentDirectory).AddJsonFile("hosting.json").Build();

                    webBuilder
        .UseConfiguration(config)
        .UseIISIntegration()
        .UseStartup<Startup>();


                })
             .ConfigureHostConfiguration(builder =>
             {
                 //启动时需要的组件配置等，比如监听的端口 url地址等
                 Console.WriteLine("ConfigureHostCOnfiguration");
                 //builder.AddJsonFile("hosting.json", true);
             });

    }
}
